package com.douwong.student.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.factory.TopicTypeFactory;
import com.douwong.student.model.Item;
import com.douwong.student.utils.ImagFilterUtil;

import java.util.List;

/**
 * @autor yichao
 * @time 2017/4/716:48
 * @des ${TODO}
 */
public class ScoreAdapter extends BaseAdapter {


    private Context mContext;
    private List<Item> mList;

    public ScoreAdapter(Context context, List<Item> list) {

        mContext = context;
        mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder=null;
        if(convertView==null){
            holder=new Holder();
            convertView= LayoutInflater.from(mContext).inflate(R.layout.score_item, null);
            holder.title=(TextView) convertView.findViewById(R.id.title);
            holder.type=(TextView) convertView.findViewById(R.id.type);
            holder.totalScore=(TextView) convertView.findViewById(R.id.totalScore);
            holder.getScore=(TextView) convertView.findViewById(R.id.getScore);
            convertView.setTag(holder);
        }else{
            holder=(Holder) convertView.getTag();
        }
        if(mList.size()>0){
           // HtmlUtils.showItemBody(holder.title,mList.get(position).getBody());
          //  holder.title.setText(mList.get(position).getIndex()+"");
            ImagFilterUtil.filterImage(holder.title,mList.get(position).getBody(),1);
            holder.type.setText(TopicTypeFactory.getTopicType(mList.get(position).getType()));
            holder.totalScore.setText(mList.get(position).getScore()+"");
            holder.getScore.setText(mList.get(position).getGetScore()+"");
        }
        return convertView;

    }
    class Holder {
        TextView title,type,totalScore,getScore;
    }
}
